feat(build): add comprehensive AOT compatibility support#267
Merged
Conversation
- Created `AotCompatibility.TestApp` to validate ahead-of-time compatibility. - Added `IsAotCompatible` property to project files for managing AOT compatibility. - Updated solution file to include the new testing project. - Configured .NET 10.0 and enabled required settings in the new project.
- Explicitly disabled AOT compatibility for `MinimalLambda.SourceGenerators` in the project file.
- Enabled additional analyzers for trimming and single-file publish. - Set `TreatWarningsAsErrors` to ensure stricter build processes. - Added project references for various envelopes and abstractions.
- Introduced `aot-check` task to validate AOT compatibility of libraries. - Updated `Directory.Build.props` with conditional analyzers for net8.0 compatibility. - Refined warnings treated as errors for improved build strictness. - Updated AOT test project to better align with compatibility requirements.
…ct settings - Added `UnconditionalSuppressMessage` attributes to suppress AOT-related warnings in envelopes. - Justifications provided to ensure safety when using source-generated `JsonSerializer` context. - Marked test projects with `<IsTestProject>` for better build system handling. - Updated `MinimalLambda.Envelopes.UnitTests` with appropriate AOT and warning configuration.
- Added `max_line_length` to XML formatting in `.editorconfig`. - Refactored `Directory.Build.props` to simplify AOT-related property configurations. - Consolidated `IsAotCompatible`, `EnableAotAnalyzer`, and `EnableTrimAnalyzer` under a single group.
…ructors check - Added `[DynamicallyAccessedMembers]` attribute to `TContext` in `AddLambdaSerializerWithContext<TContext>()`. - Ensures public constructors are preserved for AOT compatibility.
…OT warnings - Replaced `Services.Configure` with `AddOptions<>().BindConfiguration` for better AOT compatibility. - Added `UnconditionalSuppressMessage` to suppress AOT-related warnings in `TryAddLambdaHostDefaultServices`. - Enabled `EnableConfigurationBindingGenerator` in the project file to support source-generated binding.
- Added `<NoWarn>` to suppress AOT-related warnings in testing projects. - Moved `<IsAotCompatible>` to a consistent position in the main project file. - Ensured alignment with existing AOT settings across related project files.
- Added `<NoWarn>` for `AD0001` to unblock builds affected by analyzer errors in .NET 9.0. - Updated project files across multiple modules to ensure consistent suppression of the issue.
…rectives in project files - Removed `GlobalUsings.cs` files across all projects to simplify and streamline dependency management. - Added `<Using>` directives directly in `.csproj` files to explicitly manage and organize global usings. - Ensured all necessary usings are integrated for each project's build and functionality needs.
…r AOT scenarios - Updated `ServiceCollectionExtensions` to conditionally register `ILambdaSerializer` only if `RuntimeFeature.IsDynamicCodeSupported`, improving AOT support. - Refactored `AotCompatibility.TestApp` project definitions by introducing `EnvelopeRootAssembly` and `CoreRootAssembly` items. - Added `TrimmerRootAssembly` configuration to streamline project references in AOT scenarios. - Modified `DefaultEventFeature<T>` to provide better error messaging and default parameter handling for `ILambdaSerializer`.
- Introduced `Validate AOT Compatibility` step in PR and main build workflows. - Separated SonarQube start and stop actions for better task modularity. - Improved overall CI process by ensuring AOT compatibility validation.
- Replaced InvalidOperationException with ArgumentNullException in DefaultEventFeature. - Enhanced exception messaging for clarity when lambdaSerializer is not registered.
|
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #267 +/- ##
==========================================
+ Coverage 88.87% 88.89% +0.02%
==========================================
Files 132 132
Lines 3263 3270 +7
Branches 322 324 +2
==========================================
+ Hits 2900 2907 +7
Misses 247 247
Partials 116 116
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

🚀 Pull Request
📋 Summary
This PR adds comprehensive support for Ahead-of-Time (AOT) compilation compatibility across the MinimalLambda codebase. It includes AOT validation in the CI pipeline, proper configuration for enabling AOT analyzers, suppression of AOT warnings where appropriate with detailed justifications, and a dedicated test project to validate AOT compatibility.
Key Changes:
IsAotCompatible,EnableAotAnalyzer, andEnableTrimAnalyzerfor .NET 8.0+ targetsUnconditionalSuppressMessageattributes for AOT warnings (IL2026, IL3050) in envelope classes with clear justificationsAotCompatibility.TestAppproject that validates all packages can be trimmed/AOT compiledGlobalUsings.csfiles to project-level<Using>directives for better AOT compatibilityTreatWarningsAsErrors=trueglobally and added specific suppressions where needed (e.g., AD0001 for .NET 9.0)✅ Checklist
🧪 Related Issues or PRs
Closes #255
💬 Notes for Reviewers
AOT Warning Suppressions
All
UnconditionalSuppressMessageattributes in envelope classes follow the same pattern and include detailed justifications. These suppressions are safe when users provide source-generated JSON serialization contexts (which is the recommended practice for Lambda functions).Build Configuration
The AOT analyzers are only enabled for .NET 8.0+ targets to avoid compatibility issues with older frameworks. The source generators project explicitly sets
IsAotCompatible=falsesince analyzers/source generators don't run in AOT scenarios.CI Pipeline
The AOT validation runs after the SonarQube analysis and tests complete, ensuring we catch AOT compatibility issues before merging.